Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-41084: Adjust message when an f-string expression causes a SyntaxError #21084

Merged
merged 5 commits into from
Jun 26, 2020

Conversation

lysnikolaou
Copy link
Contributor

@lysnikolaou lysnikolaou commented Jun 23, 2020

Prefix the error message with f-string: , when parsing an f-string
expression which throws a SyntaxError.

https://bugs.python.org/issue41084

…Error

Prefix the error message with `fstring: `, when parsing an f-string
expression throws a `SyntaxError`.
@lysnikolaou
Copy link
Contributor Author

lysnikolaou commented Jun 23, 2020

Wow, bpo-41084 and GH-21084. 4/5 same digits is as close as it gets at the moment, I guess.

Copy link
Member

@ericvsmith ericvsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me.

const char *fstring_msg = "f-string: ";
Py_ssize_t len = strlen(fstring_msg) + strlen(errmsg);

char *new_errmsg = PyMem_RawMalloc(len + 1); // Lengths of both strings plus NULL character
Copy link
Member

@pablogsal pablogsal Jun 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be PyMem_Malloc no? Any reason why you need the raw allocator?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used PyMem_RawMalloc, because fstring_compile_expr uses it for str in string_parser.c. You know best what's more suitable here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to move them to PyMem_Malloc, but let's do that in a different PR

@pablogsal pablogsal merged commit 2e0a920 into python:master Jun 26, 2020
@pablogsal pablogsal added the needs backport to 3.9 only security fixes label Jun 27, 2020
@miss-islington
Copy link
Contributor

Thanks @lysnikolaou for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-21188 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Jun 27, 2020
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 27, 2020
…Error (pythonGH-21084)

Prefix the error message with `fstring: `, when parsing an f-string expression throws a `SyntaxError`.
(cherry picked from commit 2e0a920)

Co-authored-by: Lysandros Nikolaou <[email protected]>
miss-islington added a commit that referenced this pull request Jun 27, 2020
…Error (GH-21084)

Prefix the error message with `fstring: `, when parsing an f-string expression throws a `SyntaxError`.
(cherry picked from commit 2e0a920)

Co-authored-by: Lysandros Nikolaou <[email protected]>
@bedevere-bot

This comment has been minimized.

fasih pushed a commit to fasih/cpython that referenced this pull request Jun 29, 2020
…Error (pythonGH-21084)

Prefix the error message with `fstring: `, when parsing an f-string expression throws a `SyntaxError`.
arun-mani-j pushed a commit to arun-mani-j/cpython that referenced this pull request Jul 21, 2020
…Error (pythonGH-21084)

Prefix the error message with `fstring: `, when parsing an f-string expression throws a `SyntaxError`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants